﻿Public Class Lista_Proveedores
    Dim acceso As New acceso()
    Private Sub Lista_Proveedores_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        datos_proveedores()

        acceso.cargarCombo(cmb_Marca, "Localidad", "nombre", "idLocalidad")
        chk_todos.Checked = True
        GRB_filtro.Enabled = False
    End Sub


    Private Sub datos_proveedores()
        Dim tabla As New Data.DataTable()
        tabla = acceso.leo_tabla("VistaProveedores")
        DS_Lista_ProveedoresBindingSource.DataSource = tabla
        ReportViewer1.RefreshReport()
    End Sub

    Private Sub datos_proveedores_filtrado()
        Dim tabla As New Data.DataTable()
        tabla = acceso.leo_tabla("VistaProveedores where idLocalidad = " & cmb_Marca.SelectedValue)
        DS_Lista_ProveedoresBindingSource.DataSource = tabla
        ReportViewer1.RefreshReport()
    End Sub

    Private Sub chk_todos_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chk_todos.CheckedChanged
        If chk_todos.Checked = True Then
            GRB_filtro.Enabled = False
            datos_proveedores()
        Else
            GRB_filtro.Enabled = True
        End If

    End Sub

    Private Sub btn_filtro_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_filtro.Click
        datos_proveedores_filtrado()
    End Sub

End Class